import React from 'react';
import { Layout} from 'antd';
import 'antd/dist/antd.css'; 
import AdminAsider from './adminAsider'
import AdminHeader from './adminHeader'
import { Switch,Route, Redirect} from 'react-router-dom'
import Home from '../home/home';
import Create from '../create/create';
import Manage from '../manage/manage';
import Bug from '../bug/bug.js';

import './asider.css';
import './content.css';
import './footer.css';
import Users from '../user/user'
const {Content, Footer, Sider } = Layout;



export default class AdminMain extends React.Component {

    componentDidMount(){
        let cookie = document.cookie;
        // cookie ? this.props.history('/login'):null;
    }

    render() {
        return(
            <Layout style={{height:'100vh' }}>
                <Sider width={200} theme="light" className="sider">
                    <AdminAsider />
                </Sider>

                <Layout >
                    <AdminHeader history={this.props.history} />
                    <Content className="content"
                    > 
                    <Switch >
                        <Route path='/home' component={Home} history={this.props.history}/>
                        <Route path="/create/" component={Create} />
                        <Route path="/create/:id" component={Create} />
                        <Route path='/manage' component={Manage} />
                        <Route path='/users' component={Users} />
                        <Route path='/bug' component={Bug} />
                        {/* <Redirect to='/home'></Redirect> */}
                       
                         <Redirect to='/error'></Redirect> 

                    </Switch> 
                    </Content>

                    <Footer className="footer">你的问题在于读的太少而想的太多。 --杨绛</Footer>
                </Layout>
            </Layout>
            
        )
    }
}